//
//  ZLApplicationExtension.swift
//  ZLExtension
//
//  Created by KDWL on 2023/1/9.
//

import Foundation

public extension UIApplication {
    /// app名称
    class func zl_appName() -> String {
        let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String ?? ""
        return appName
    }
    /// appBundleID
    class func zl_appBundleID() -> String {
        let bundleID = Bundle.main.object(forInfoDictionaryKey: "CFBundleIdentifier") as? String ?? ""
        return bundleID
    }
    /// app版本号
    class func zl_appVersion() -> String {
        let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? ""
        return version
    }
    /// app构建版本号
    class func zl_appBuildVersion() -> String {
        let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? ""
        return version
    }
    /// 打开设置
    class func zl_openSetting() {
        if let appSettings = URL(string: UIApplication.openSettingsURLString) {
            if UIApplication.shared.canOpenURL(appSettings) {
                UIApplication.shared.open(appSettings, options: [:], completionHandler: nil)
            }
        }
    }
}
